My three plots

I am looking at Instacart data.

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.4     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   2.0.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(p8105.datasets)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Subset of Instacart Data

data("instacart")
instacart_subset = 
instacart %>% 
  mutate(mean_hour = mean(order_hour_of_day)) %>%
  select(product_name, order_dow, order_hour_of_day, aisle, department, mean_hour) %>% 
  mutate(
    order_dow = 
      recode_factor(order_dow, "0" = "Monday", "1" = "Tuesday", "2" = "Wednesday", "3" = "Thursday", "4" = "Friday", "5" = "Saturday", "6" = "Sunday"))

Chart 1

instacart_subset %>% 
  filter(
    department == "produce"
  ) %>% 
  count(product_name) %>% 
  plot_ly(
    x = ~product_name, y = ~n, type = "scatter", mode = "markers")

This shows the number of each item in the produce department.

Chart 2

instacart_subset %>% 
  plot_ly(y = ~department, color = ~order_dow, type = "box", colors = "viridis")

This is also a suspiciously uniform plot… I’m guessing it reflects something about how the data is input from user activity.

Chart 3

instacart_subset %>% 
  count(aisle) %>% 
  filter(n > 20000) %>% 
  plot_ly(x = ~aisle, y = ~n, color = ~aisle, type = "bar", colors = "viridis")

This shows the count of products sold in each aisle among those with over 20,000 products sold.